Interface presentation

Interface for showing tool overlays and graphics in the Nova viewer.

The interface is acquired from output:getPresentation() within the execute-method of a tool.

presentation:add(obj)
Arguments:

Adds overlay graphics to the viewer. Suitable for adding tool result information, like positions or center-points (Point), included pixel content (Image.PixelRegion) or various shapes (Shape).

Note

When the argument to add is a list, like Point[] or Image.PixelRegion[], all entries in the list must be of the same type:

Adding a list of points
local presentation = output:getPresentation()
presentation:add({Point.create(10, 10),
                  Point.create(20, 20),
                  Point.create(30, 30)})

presentation:addRegion(region, heightRange)
Arguments:

Include the tool regions in what gets presented in the Viewer.

The optional second argument is a table with {minHeightRange, maxHeightRange} that should only be sent when the tool has registered support for 3D regions. The height range is normally taken from the return value of input.getTransformedRegion.

presentation:addText(text, decoration)
Arguments:

Add text to the viewer.

The decoration argument can be used to set the color, position and size of the text.

Example use

The following code uses the presentation interface and constants from the Tool-module for sizes and colors.

local image = input:getImage()

local redTextDecoration = View.TextDecoration.create()
redTextDecoration:setColor(Tool.color.red())
redTextDecoration:setSize(30)
redTextDecoration:setPosition(300,300)
presentation:addText("This text is red", redTextDecoration)

local yellowTextDecoration = View.TextDecoration.create()
yellowTextDecoration:setColor(Tool.color.yellow())
yellowTextDecoration:setSize(30)
yellowTextDecoration:setPosition(300,400)
presentation:addText("This text is yellow", yellowTextDecoration)

local yellowAlpha = View.PixelRegionDecoration.create()
yellowAlpha:setColor(Tool.color.yellowTranslucent())
local blueAlpha = View.PixelRegionDecoration.create()
blueAlpha:setColor(Tool.color.blueTranslucent())

local pixRectangle1 = Shape.createRectangle(
  Point.create(500,500), 100, 100
):toPixelRegion(image)
local pixRectangle2 = Shape.createRectangle(
  Point.create(550,550), 100, 100
):toPixelRegion(image)
presentation:add(pixRectangle1, yellowAlpha)
presentation:add(pixRectangle2, blueAlpha)

This code will produce this visualization:

../../_images/overview-overlays.png